<?
$dbconnsqli = new mysqli($dbhost,$dbuser,$dbpass,$dbname);

if($dbconnsqli->connect_errno > 0){
    die('Unable to connect to database [' . $dbconnsqli->connect_error . ']');
}
	$dbconnsqli->query("SET character_set_results=utf8");
    $dbconnsqli->query("set names 'utf8'");
function stripslashes_deep($value)
{
    $value = is_array($value) ?
                array_map('stripslashes_deep', $value) :
                stripslashes($value);

    return $value;
}
function query($sql){
	global $dbconnsqli;
	return $dbconnsqli->query($sql);	
}

function insert($post,$table){
		global $dbconnsqli;
		foreach ($post as $colss => $values)
		{
			$cols[]=$colss;
			$value[]="'".$dbconnsqli->real_escape_string($values)."'";
		}
		return $dbconnsqli->query("INSERT INTO {$table} (".join(", ",$cols).") VALUES (".join(", ",$value).")");
}

function update($post,$table,$where){
		global $dbconnsqli;
		foreach ($post as $cols => $value)
		{			
			$update[]="{$cols}='".$dbconnsqli->real_escape_string($value)."'";		
		}		
		$update=join(", ",$update);
		return $dbconnsqli->query("UPDATE {$table} SET {$update} WHERE $where");
}

function fetch($sql){
		global $dbconnsqli;
		return stripslashes_deep($sql->fetch_assoc());
}
function numrows($sql)
{
	global $dbconnsqli;
	return $sql->num_rows;
}

function selonce($query)
{
	global $dbconnsqli;
	return fetch(query($sql));
}
function get_insert_id()
{
	global $dbconnsqli;
	return $dbconnsqli->insert_id;
}

?>